﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Gtkj.CMS.App.Models
{
    public class MyExceptionAttribute : HandleErrorAttribute
    {
        public static Queue<Exception> ExceptionQueue = new Queue<Exception>();
        public override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);
            ExceptionQueue.Enqueue(filterContext.Exception);//将异常信息添加到队列中。
            string url = filterContext.Controller.ToString(); ;
            if (url.Contains("Gtkj.CMS.App.Areas.AdminInfo"))
            {
                filterContext.HttpContext.Response.Write(filterContext.Exception.Message);
            }
            else
            {
                filterContext.HttpContext.Response.Write(filterContext.Exception.Message);
            }
            
            filterContext.HttpContext.Response.End();
        }
    }
}